Skip to content

Comments

[CHA-610] Draft messages#161

Merged
nijeesh-stream merged 7 commits intomasterfrom
draft_messages
Apr 4, 2025
Merged

[CHA-610] Draft messages#161
nijeesh-stream merged 7 commits intomasterfrom
draft_messages

Conversation

@nijeesh-stream
Copy link
Contributor

Submit a pull request

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested (add some information if not applicable)

Description of the pull request

Changes

  • Added comprehensive test cases for query_drafts method in client_spec.rb
  • Implemented draft message querying functionality in client.rb

Test Coverage

The new test cases cover the following scenarios:

  • Creating multiple drafts in different channels
  • Querying all drafts for a user
  • Filtering drafts by specific channel
  • Sorting drafts by creation time
  • Pagination with limit and next cursor
  • Proper cleanup of test resources

Implementation Details

  • Added query_drafts method to StreamChat::Client class
  • Method accepts:
    • user_id (required): The ID of the user to query drafts for
    • filter (optional): Filter conditions for the query
    • sort (optional): Sort parameters
    • options (optional): Additional query options like pagination

Example Usage

# Query all drafts for a user
client.query_drafts(user_id)

# Query drafts with filter
client.query_drafts(user_id, filter: { 'channel_cid' => channel.cid })

# Query drafts with sorting
client.query_drafts(user_id, sort: [{ 'field' => 'created_at', 'direction' => 1 }])

# Query drafts with pagination
client.query_drafts(user_id, options: { limit: 1 })

Testing

All test cases have been verified to work with the Stream Chat API. The tests ensure:

  • Correct draft creation and retrieval
  • Proper filtering and sorting
  • Accurate pagination handling
  • Clean resource management

Related

  • Implements draft message querying functionality as per Stream Chat API specifications
  • Maintains consistency with existing Ruby client patterns
  • Follows the same test structure as other client methods

- Added methods to create, get, and delete draft messages in the Channel class.
- Introduced a method to query draft messages in the Client class.
- Added corresponding tests for draft message functionality in channel_spec.rb and client_spec.rb.
@shaljam shaljam changed the title [] Draft messages [CHA-610] Draft messages Apr 2, 2025
@nijeesh-stream nijeesh-stream merged commit c7bccb3 into master Apr 4, 2025
4 checks passed
@nijeesh-stream nijeesh-stream deleted the draft_messages branch April 4, 2025 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants